<!DOCTYPE html>
<html lang="zh-cmn-Hans">
  <head>
    <meta charset="UTF-8">
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
    <meta content="yes" name="apple-mobile-web-app-capable" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <meta name="format-detection" content="telephone=no" />
    <link rel="stylesheet" href="../../../static/mobile/default/css/layout.css?v=2"/>
    <link rel="icon" type="image/png" href="../../../static/favicon.ico"/>
    <script src="../../../static/js/jquery/jquery/2.1.4/jquery.min.js"></script>
    <script src="../../../static/js/jquery/jquery.cookie.js"></script>
        <script src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
        <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
    <script src="../../../static/mobile/default/js/page.js?v=1"></script>
    <title>发起合同  - 达漂亮</title>
          
<link rel="stylesheet" href="../../../static/mobile/default/css/picker.css"/>
<link rel="stylesheet" href="../../../static/mobile/default/js/Swiper-4.0.7/swiper.min.css" />
<link rel="stylesheet" href="../../../static/mobile/default/css/userData.css" />
<link rel="stylesheet" href="../../../static/mobile/default/css/orderDetails.css" />


</head>
<body >
  <div class="page myOrder">
    		<div class="page-hd">
            <div class="header base-header bor-1px-b">
                <div class="header-left">
                    <a href="javascript:history.go(-1)" class="left-arrow"></a>
                </div>
                <div class="header-title">发起合同</div>
                <div class="header-right">
                    <!-- <a href=""></a> -->
                </div>
            </div>
        </div>
      
      <div class="page-bd ">
          <!-- 页面内容-->

    <div class="tabBox">
        <div class="block allBox">
            <form id="userform">
        <!-- 页面内容-->
        <div class="cells">
         
           <div class="cell">
              <div class="cell_bd">
            <span class="fs28 color_9">合同范本</span></div>

          </div>
          
          <div class="cell " style=" width: 100%;   height: 3.5rem;">
            <div class="swiperGird" style="width: 100%;  background-color: #fff;">
                <div class="swiper-container swiper1" id="swiper01" style="width: 100%;  background-color: #fff;">
                    <div class="swiper-wrapper contractContent">


                    </div>
                </div>
                <!-- 功能入口 -->
            </div>
           </div> 
          <div class="cell">
              <div class="cell_bd">
            <span class="fs28 color_9">截至日期</span></div>
            <div class="cell_ft">
                默认签署截至日期是7天
            </div>
          </div>
          <div class="cell">
              <div class="cell_bd">
            <span class="fs28 color_9">乙方用户ID</span></div>
            <div class="cell_ft">
                <input type="number" value="" name="recvUserId" class="fs28 color_3 fw_b inputbox" placeholder="请输入">
            </div>
          </div>

                <div class="cell_bd personal" style="margin-top:.4rem;     text-align: center;" ><span class="fs28 color_3 fw_b" style="    background: #f65236;
    color: white;
    width: 2rem;
    display: inline-block;
    padding: .1rem 0;
    border-radius: 20px;">确认</span></div>
  
                  </div> 
         
        </form>
        </div>
       
    </div>
      
        
        <!--<div class="page-ft">-->
        <!--    <span class="fs32 color_w fw_b BGcolor_r postBtn">保存</span>-->
        <!--  </div>-->

</div>
     

  </div>
  
  <script type="text/html" id="contractTpl">
    {{each data as item index}}
     <div  class="swiper-slide" style="width: 2rem; height: 2.5rem;padding:0 0.1rem;">
       
        <label  style="background:url({{item.tplImg}}) no-repeat;width: 100%;height: 2.2rem;    background-size: 100% 100%;position: relative;">
            <div class="iconBox" style="    top: 0;position: absolute;right: 0;">
                <input type="radio" class="check" name="tplId" value="{{item.id}}" data-tplName ='{{item.tplName}}'>
                <i class="icon_checked"></i>
            </div>
            
        </label>
        <a  href="https://mp.jianguoes.com//build/build/generic/web/viewer.html?file={{item.tplUrl}}" traget='_blank' style="    text-align: center;width: 1rem;position: absolute;top: 45%;left: 50%;transform: translate(-50%,-50%);background: #f65236;padding: .05rem .1rem;border-radius: 20px; color: #fff;">点击预览</a>
        <p class="fs22"  style="text-align:center">{{item.tplName}}</p>
        </div>
    {{/each}}
</script>
<script src="../../../static/mobile/default/js/Swiper-4.0.7/swiper.min.js"></script>
<script src="../../../static/js/art-template.js"></script>
<script src="../../../static/mobile/default/js/lib/fastclick.js"></script>
<script src="../../../static/js/jquery/lazyload/jquery.lazyload.js"></script>
<!--<script src="../../../static/mobile/default/js/uploadsimage.js?v=1"></script>-->
<script>
    $(function() {
        FastClick.attach(document.body);
		$("img.lazy").lazyload({effect:"fadeIn",event:"scroll",container:$(".page-bd")});
    });
    
          share()
     function  share(){
    /***用户点击分享到微信圈后加载接口接口*******/
        var url=window.location.href;
        console.log("url:"+url);
            $.ajax({
		    url: "/api/mp/wxconfig",
		    type: "post",
		    data:{shareUrl:url},
		    headers:{ token: $.cookie('code')},
		    dataType: "json",
		    success: function(data){
		         configData = {
                    debug : false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
                    appId: data.data.appid, // 必填，公众号的唯一标识
                    timestamp: data.data.timestamp, // 必填，生成签名的时间戳
                    nonceStr: data.data.nonceStr, // 必填，生成签名的随机串
                    signature: data.data.signature,// 必填，签名，见附录1
                    jsApiList : ['hideOptionMenu']
                    // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
               };
               
               //step2:注入配置信息
               wx.config(configData);
               //step3:通过ready接口处理成功验证
               wx.ready(function () {
                   // config信息验证后会执行ready方法，所有接口调用都必须在config接口获得结果之后，config是一个客户端的异步操作，所以如果需要在页面加载时就调用相关接口，则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口，则可以直接调用，不需要放在ready函数中。
//                 alert("执行ready方法");
//                 wx.checkJsApi({
//                      jsApiList: ['chooseImage'] // 需要检测的JS接口列表，所有JS接口列表见附录2,
//                      success: function(res) {
//                      // 以键值对的形式返回，可用的api值true，不可用为false
//                      // 如：{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"}
//                      }
//                 });
                   //接口1:获取网络类型
                    wx.getNetworkType({
                        success: function (res) {
                          oldNet = res.networkType; // 返回网络类型2g，3g，4g，wifi
//                        alert("网络类型"+ oldNet);
                        }
                     });
                   //禁用右上角菜单按钮
                   wx.hideOptionMenu();
		    })
		    },
		    error: function() {
// 			    _alert('ajax request failed!!!!');
			    return;
		    } 
        })

	    
	    
	    }
    

</script>

<script src="../../../static/mobile/default/js/datePicker.js"></script>
<script src="../../../static/mobile/default/js/picker.min.js"></script>
 <script>
 var nowPage = [],getAgain = [],isLoadend = [];
 var _type = 'all';
    
      $(function(){

        
        
        	$.ajax({
		  url: '/api/mp/listContractTpl',
		  type: 'get',
		  headers:{'token': $.cookie('code')},
		  contentType: "application/json",
		  success: function (res) {

		      if (res.errno != 0){
				  _alert(res.errmsg);
				  return false;	
			  }
			  
			  $('.contractContent').append(template('contractTpl',res))
			   var swiper = new Swiper(".swiper1" , {
                  slidesPerView: 3,
                });

			
             
		  }
	})
      })



$('.personal').click(function(){
    
     if(!$('input[name=tplId]').is(':checked')){
         _alert('请选择合同');
         return
    }else if(!$('input[name=recvUserId]').val()){
        _alert('请输入乙方用户ID');
        return
    }
     _alert('确定向ID号为'+$('input[name=recvUserId]').val()+'发起合同吗？',function(){
         
         submit()
     });
})

function submit(){
     
    
    var date = new Date();
    date.getFullYear()+"年 0"+(date.getMonth()+1)+"月"
    let array = '';
	var data = $('#userform').toJson();
	data.contractName = $("input[name='tplId']:checked").attr('data-tplName')+date.getFullYear()+""+(date.getMonth()+1)+""+date.getDay()
	
	$.ajax({
		  url: '/api/mp/sendContract',
		  type: 'post',
		  headers:{'token': $.cookie('code')},
		  contentType: "application/json",
		  data: JSON.stringify(data),
		  success: function (res) {

		      if (res.errno != 0){
				  _alert(res.errmsg);
				  return false;	
			  }
			  _alert('发起合同成功');
			  setTimeout(function() {
			      window.location.href ='./contract.html'
			  }, 2000);
			  
             
		  }
	})
}


</script>


  <div class="alertBox">
      <div class="alertBG"></div>
      <div class="alert">
          <div class="text fs30 color_3 bor_b">

          </div>
          <!-- 单按钮 -->
          <div class="button fs32 fw_b color_r">
              知道了
          </div>
          <!-- 双按钮 -->
          <div class="buttonBox fs32 fw_b">
              <span class="color_9 bor_r cancel">取消</span>
              <span class="color_r confirm">确定</span>
          </div>
      </div>
  </div>
  <script type="text/javascript">
      var is_xcx = 0;
      $(document).on('click', 'a', function () {
          var href = $(this).attr('href');
          if (href.indexOf('/pages') != -1) {
              if (is_xcx == 1) {
                  wx.miniProgram.navigateTo({
                      url: href
                  })
                  return false;
              } else {
                  return false;
              }
          }
      })
  </script>
    </body>
</html>